package com.enbatis.mybatisplugs.base;

import com.enbatis.mybatisplugs.commons.sql.Wrapper;
import com.enbatis.mybatisplugs.commons.utils.BaseSqlProvider;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

public interface BaseMapper<T> {

        @InsertProvider(method = "insert",type= BaseSqlProvider.class)
        int insert(T entity);


        @InsertProvider(method = "saveBatch",type= BaseSqlProvider.class)
        int saveBatch(@Param("list") Collection<T> entityList,Class clazz);


        @SelectProvider(method = "getById",type= BaseSqlProvider.class)
        T getById(@Param("tableName") String tableName, @Param("id") Serializable id);

        //修改一条数据
        @UpdateProvider(method = "updateById",type=BaseSqlProvider.class)
        int updateById(@Param("tableName")String tableName,@Param("bean") T bean);

        @SelectProvider(method = "list",type= BaseSqlProvider.class)
        List<T> list(Wrapper<T> wrapper);


        @SelectProvider(method = "list",type= BaseSqlProvider.class)
        List<T> page(Wrapper<T> wrapper);


        @UpdateProvider(method = "update",type=BaseSqlProvider.class)
        int update(T bean,Wrapper<T> wrapper);


        @SelectProvider(method = "selectCount",type=BaseSqlProvider.class)
        int selectCount(Wrapper<T> wrapper);




        @DeleteProvider(method = "deleteById",type= BaseSqlProvider.class)
        int deleteById(@Param("tableName") String tableName, @Param("id") Serializable id);

}
